package org.uniport.dao.proxy;

import org.uniport.dao.IPhotoDAO;
import org.uniport.dao.impl.PhotoDAOImpl;
import org.uniport.dbc.DatabaseConnection;
import org.uniport.vo.Photo;

public class PhotoDAOProxy implements IPhotoDAO {
	
	private DatabaseConnection dbc= null;
    private IPhotoDAO dao = null; //problem?
    public PhotoDAOProxy(){
            try{
                    this.dbc = new DatabaseConnection();
            }catch(Exception e){
                    e.printStackTrace();
            }
            this.dao = new PhotoDAOImpl(dbc.getConnection());
    }
	
	public boolean addPhoto(Photo photo) throws Exception {
		boolean flag = false;
        try{
                flag = this.dao.addPhoto(photo);
        }catch(Exception e){
                throw e;
        }finally{
                this.dbc.close();
        }
        return flag;
	}

	
	public int findPhotoID(String addr) throws Exception {
		int photoID = -1;
		try{
            photoID = this.dao.findPhotoID(addr);
		}catch(Exception e){
			throw e;
		}finally{
            this.dbc.close();
		}
		return photoID;
	}

}
